package com.lq.ecoldchain.ui.mine.suggestion

import android.widget.EditText
import com.lq.ecoldchain.base.CommonLoadingViewModel
import kotlinx.android.synthetic.main.activity_suggestion.*
import org.kodein.di.Kodein
import org.kodein.di.android.support.AndroidLifecycleScope
import org.kodein.di.generic.bind
import org.kodein.di.generic.instance
import org.kodein.di.generic.scoped
import org.kodein.di.generic.singleton

/*
*2018/12/25 0025  15:25
*function by lq
*/
const val SUGGESTION_MODULE ="suggestion_kodein_module"
val suggestionModule = Kodein.Module(SUGGESTION_MODULE){

    bind<EditText>() with scoped(AndroidLifecycleScope).singleton {
        (context as SuggestionActivity).suggestionEt
    }
    bind<SuggestionViewModel>() with scoped(AndroidLifecycleScope).singleton {
        SuggestionViewModel()
    }

    bind<SuggestionDelegate>() with scoped(AndroidLifecycleScope).singleton {
        SuggestionDelegate(
                viewModel = SuggestionViewModel(),
                edit = instance(),
                loadingViewModel = CommonLoadingViewModel.instance(context)
        )
    }
}